Skip to content

Conversation

@beeankha
Copy link
Contributor

@beeankha beeankha commented Sep 9, 2025

Resolves AAP-51478

A new helper function for generating a unique name for an AAP resource. The function appends the resource name from the pattern definition with the collection name and pattern name, plus a short hash generated from the combination of the collection name, pattern name, collection version, and organization ID.

This new unique name is in the format of:
{original_resource_name} {collection_name}.{pattern_name} {hash}

task.mark_running({"info": "Creating job templates"})
automations = create_job_templates(
session, instance, pattern_def, project_id, ee_id
session, instance, pattern, pattern_def, project_id, ee_id
Copy link
Contributor

@alinabuzachis alinabuzachis Sep 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not understand the reason you need to pass pattern instance here. Cannot you access the information needed from pattern_def already? If that's not the case, I would only pass the pattern instance and remove pattern_def, because pattern_def can be obtained pattern_def = pattern.pattern_definition inside create_job_templates.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated accordingly!

@beeankha beeankha force-pushed the aap-resource-name-hash branch from d4f6f06 to bcaa3ba Compare September 17, 2025 00:25
Copy link
Contributor

@abikouo abikouo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Creates controller labels and returns model instances.
Args:
instance (PatternInstance): The PatternInstance object.
pattern (Pattern): The related Pattern object.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this something that need to be removed?

Copy link
Contributor

@GomathiselviS GomathiselviS left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Docstring update needed. Otherwise LGTM.

@sonarqubecloud
Copy link

@beeankha beeankha merged commit 27f4d8b into ansible:main Sep 17, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants